//
//  OSCCommentTools.m
//  OSChina
//
//  Created by 8b410-2 on 17/1/7.
//  Copyright © 2017年 abb. All rights reserved.
//

#import "OSCCommentTools.h"

@implementation OSCCommentTools

+ (RACSignal *)requestCommentWithParamsModel:(OSCCommentRequestParams *)params {
    return [[[OSCNetAPIClient shareJsonClient]
             requestJsonDataWithPath:comment_list Params:[params mj_keyValues]]
            map:^id(NSDictionary *dict) {
                // 拿到模型字典
                NSArray *modelsDict = [dict valueForKey:@"commentList"];
                // 转模型
                return [OSCComment mj_objectArrayWithKeyValuesArray:modelsDict];
            }];
}

+ (RACSignal *)requestPubCommentWithParamsModel:(OSCPubCommentRequestParams *)params {
    return [[[OSCNetAPIClient shareJsonClient]
            requestJsonDataWithPath:comment_pub Params:[params mj_keyValues]]
            map:^id(NSDictionary *dict) {
                NSInteger code = [[dict valueForKey:@"error"] integerValue];
                NSString *resultString = [dict valueForKey:@"error_description"];
                if (code == 200) {
                    return resultString;
                } else {
                    return resultString;
                }
            }];
}
@end
